import { defHttp } from '/@/utils/http/axios';
import { IGetGetConfigResponse } from '/@/types/getConfig';
import { IPostRegisterRequest } from '/@/types/register';
import { IPostLoginRequest, IPostLoginResponse } from '/@/types/login';
import { IGetGetUserInfoResponse } from '/@/types/getUserInfo';
import { IGetGetRoutersResponse } from '/@/types/getRouters';
import { IGetGetPermCodeResponse } from '/@/types/getPermCode';
import { IGetCaptchaImageResponse } from '/@/types/captchaImage';

/**
 * /getConfig
 */
export const apiGetConfig = () => defHttp.get<IGetGetConfigResponse>({ url: `/getConfig` });
/**
 * 注册接口
 */
export const apiPostRegister = (params: IPostRegisterRequest) =>
  defHttp.post({ url: `/register`, params });
/**
 * 登录
 */
export const apiPostLogin = (params: IPostLoginRequest) =>
  defHttp.post<IPostLoginResponse>({ url: `/login`, params });
/**
 * 获取当前登录用户信息
 */
export const apiGetUserInfo = () => defHttp.get<IGetGetUserInfoResponse>({ url: `/getUserInfo` });
/**
 * 获取用户对应的菜单路由
 */
export const apiGetRouters = () => defHttp.get<IGetGetRoutersResponse>({ url: `/getRouters` });
/**
 * 获取用户角色和权限码
 */
export const apiGetPermCode = () => defHttp.get<IGetGetPermCodeResponse>({ url: `/getPermCode` });
/**
 * 首页
 */
export const apiGet = () => defHttp.get({ url: `/` });
/**
 * 验证码
 */
export const apiGetCaptchaImage = () =>
  defHttp.get<IGetCaptchaImageResponse>({ url: `/captchaImage` });
